|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--jade.core.behaviours.Behaviour
|
+--jade.core.behaviours.CompositeBehaviour
An abstract superclass for behaviours composed by many parts. This
class holds inside a number of children behaviours.
When a CompositeBehaviour receives it execution quantum
from the agent scheduler, it executes one of its children according
to some policy. This class must be extended to provide the actual
scheduling policy to apply when running children behaviours.
SequentialBehaviour,
ParallelBehaviour,
FSMBehaviour, Serialized Form| Inner classes inherited from class jade.core.behaviours.Behaviour |
Behaviour.RunnableChangedEvent |
| Field Summary | |
protected boolean |
currentExecuted
|
| Fields inherited from class jade.core.behaviours.Behaviour |
myAgent,
myEvent,
NOTIFY_DOWN,
NOTIFY_UP,
parent |
| Constructor Summary | |
protected |
CompositeBehaviour()
Default constructor, does not set the owner agent. |
protected |
CompositeBehaviour(Agent a)
This constructor sets the owner agent. |
| Method Summary | |
void |
action()
Executes this CompositeBehaviour. |
void |
block()
Blocks this behaviour. |
protected abstract boolean |
checkTermination(boolean currentDone,
int currentResult)
This methods is called after the execution of each child in order to check whether the CompositeBehaviour
should terminate. |
boolean |
done()
Checks whether this behaviour has terminated. |
protected abstract Collection |
getChildren()
This method returns a Collection view of the children of this CompositeBehaviour |
protected abstract Behaviour |
getCurrent()
This method returns the child behaviour currently scheduled for execution |
int |
onEnd()
Overrides the onEnd() method in the
Behaviour class by simply calling the
postAction() method for backward compatibility. |
void |
onStart()
Overrides the onStart() method in the
Behaviour class by simply calling the
preAction() method for backward compatibility. |
protected void |
postAction()
Deprecated. Use onEnd() instead.
This method is just an empty placeholder for subclasses. It is
invoked just once after this behaviour has ended. Therefore,
it acts as an epilog for the composite task represented by this
CompositeBehaviour. |
protected void |
preAction()
Deprecated. Use onStart() instead.
This method is just an empty placeholders for subclasses. It is
executed just once before starting children
scheduling. Therefore, it acts as a prolog to the composite
task represented by this CompositeBehaviour. |
void |
reset()
Puts a CompositeBehaviour back in initial state. |
void |
restart()
Restarts this behaviour. |
protected abstract void |
scheduleFirst()
This method schedules the first child to be executed |
protected abstract void |
scheduleNext(boolean currentDone,
int currentResult)
This method schedules the next child to be executed |
| Methods inherited from class jade.core.behaviours.Behaviour |
actionWrapper,
block,
getDataStore,
handle,
isRunnable,
root,
setAgent,
setDataStore |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected boolean currentExecuted
| Constructor Detail |
protected CompositeBehaviour()
protected CompositeBehaviour(Agent a)
a - The agent this behaviour belongs to.| Method Detail |
public final void action()
CompositeBehaviour. This method
executes children according to the scheduling policy
defined by concrete subclasses that implements
the scheduleFirst() and scheduleNext()
methods.CompositeBehaviourpublic final boolean done()
true if this CompositeBehaviour
has finished executing, falseotherwise.protected abstract void scheduleFirst()
protected abstract void scheduleNext(boolean currentDone,
int currentResult)
currentDone - a flag indicating whether the just executed
child has completed or not.currentResult - the termination value (as returned by
onEnd()) of the just executed child in the case this
child has completed (otherwise this parameter is meaningless)
protected abstract boolean checkTermination(boolean currentDone,
int currentResult)
CompositeBehaviour
should terminate.currentDone - a flag indicating whether the just executed
child has completed or not.currentResult - the termination value (as returned by
onEnd()) of the just executed child in the case this
child has completed (otherwise this parameter is meaningless)CompositeBehaviour
should terminate. false otherwise.protected abstract Behaviour getCurrent()
protected abstract Collection getChildren()
CompositeBehaviourpublic void block()
block() is called
all its children are notified too.Behaviour.restart()public void restart()
restart() is called
all its children are notified too.Behaviour.block()public void reset()
CompositeBehaviour back in initial state. The
internal state is cleaned up and reset() is
recursively called for each child behaviour.public void onStart()
onStart() method in the
Behaviour class by simply calling the
preAction() method for backward compatibility.Behaviour.onStart()public int onEnd()
onEnd() method in the
Behaviour class by simply calling the
postAction() method for backward compatibility.Behaviour.onEnd()protected void preAction()
onStart() instead.
This method is just an empty placeholders for subclasses. It is
executed just once before starting children
scheduling. Therefore, it acts as a prolog to the composite
task represented by this CompositeBehaviour.
protected void postAction()
onEnd() instead.
This method is just an empty placeholder for subclasses. It is
invoked just once after this behaviour has ended. Therefore,
it acts as an epilog for the composite task represented by this
CompositeBehaviour.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||